/**
 * 
 */
package com.yk.neon.lib.util.result;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;

/**
 * @description:
 * @author: yang ke
 * @date: 2022/4/19
 */
public enum HttpCode implements Code<String> {
	/**
	 * 返回码
	 */
	SUCCESS("200", "请求成功"), BAD_REQUEST("400", "客户端请求错误"), UNAUTHORIZED("401", "未授权请求"), METHOD_NOT_ALLOWED("405", "方法不支持"), @Deprecated
	INVALID("403", "参数错误"), SERVER_ERROR("500", "服务端异常，请联系管理员"), @Deprecated
	EXIST("202", "数据已存在"), @Deprecated
	NODATA("204", "数据不存在");

	private String value;
	private String desc;

	HttpCode(String value, String desc) {
		this.value = value;
		this.desc = desc;
	}


	@JsonValue
	@Override
	public String value() {
		return this.value;
	}

	@Override
	public String desc() {
		return this.desc;
	}

	@Override
	public boolean isSame(String state) {
		return value.equals(state);
	}


	@JsonCreator
	public static HttpCode getEnum(String value) {
		for (HttpCode code : values()) {
			if (code.value().equals(value)) {
				return code;
			}
		}
		return null;
	}

}
